unsigned long * list;
unsigned long curr;
unsigned long page;
+ struct list_head *list_ent;
list = (unsigned long *)map_domain_mem(p->pg_head << PAGE_SHIFT);
- curr = p->pg_head;
- *list++ = p->pg_head;
- page = (frame_table + p->pg_head)->next;
- while(page != p->pg_head){
- if(!((unsigned long)list & (PAGE_SIZE-1))){
- curr = (frame_table + curr)->next;
- unmap_domain_mem((unsigned long)(list-1) & PAGE_MASK);
+ curr = page = p->pg_head;
+ do {
+ *list++ = page;
+ list_ent = frame_table[page].list.next;
+ page = list_entry(list_ent, struct pfn_info, list) - frame_table;
+ if( !((unsigned long)list & (PAGE_SIZE-1)) )
+ {
+ list_ent = frame_table[curr].list.next;
+ curr = list_entry(list_ent, struct pfn_info, list) - frame_table;
+ unmap_domain_mem(list-1);
list = (unsigned long *)map_domain_mem(curr << PAGE_SHIFT);
}
- *list++ = page;
- page = (frame_table + page)->next;
}
- unmap_domain_mem((unsigned long)(list-1) & PAGE_MASK);
+ while ( page != p->pg_head );
+ unmap_domain_mem(list);
}
long do_dom0_op(dom0_op_t *u_dom0_op)
int i;
unsigned long pfn = op.u.getmemlist.start_pfn;
unsigned long *buffer = op.u.getmemlist.buffer;
+ struct list_head *list_ent;
for ( i = 0; i < op.u.getmemlist.num_pfns; i++ )
{
/* XXX We trust DOM0 to give us a safe buffer. XXX */
*buffer++ = pfn;
- pfn = (frame_table + pfn)->next;
+ list_ent = frame_table[pfn].list.next;
+ pfn = list_entry(list_ent, struct pfn_info, list) - frame_table;
}
}
break;
temp = free_list.next;
/* allocate first page */
- pf = list_entry(temp, struct pfn_info, list);
+ pf = pf_head = list_entry(temp, struct pfn_info, list);
pf->flags |= p->domain;
temp = temp->next;
list_del(&pf->list);
- pf->next = pf->prev = p->pg_head = (pf - frame_table);
+ INIT_LIST_HEAD(&pf->list);
+ p->pg_head = pf - frame_table;
pf->type_count = pf->tot_count = 0;
free_pfns--;
- pf_head = pf;
/* allocate the rest */
- for(alloc_pfns = req_pages - 1; alloc_pfns; alloc_pfns--){
+ for ( alloc_pfns = req_pages - 1; alloc_pfns; alloc_pfns-- )
+ {
pf = list_entry(temp, struct pfn_info, list);
pf->flags |= p->domain;
temp = temp->next;
list_del(&pf->list);
- pf->next = p->pg_head;
- pf->prev = pf_head->prev;
- (frame_table + pf_head->prev)->next = (pf - frame_table);
- pf_head->prev = (pf - frame_table);
+ list_add_tail(&pf->list, &pf_head->list);
pf->type_count = pf->tot_count = 0;
free_pfns--;
int final_setup_guestos(struct task_struct * p, dom_meminfo_t * meminfo)
{
+ struct list_head *list_ent;
l2_pgentry_t * l2tab;
l1_pgentry_t * l1tab;
start_info_t * virt_startinfo_addr;
do_process_page_updates_bh(pgt_updates, 1);
pgt_updates++;
if(!((unsigned long)pgt_updates & (PAGE_SIZE-1))){
- unmap_domain_mem((void *)((unsigned long)(pgt_updates-1) & PAGE_MASK));
- curr_update_phys = (frame_table + (curr_update_phys >> PAGE_SHIFT))->next
- << PAGE_SHIFT;
- pgt_updates = (page_update_request_t *)map_domain_mem(curr_update_phys);
+ unmap_domain_mem(pgt_updates-1);
+ list_ent = frame_table[curr_update_phys >> PAGE_SHIFT].list.next;
+ curr_update_phys = list_entry(list_ent, struct pfn_info, list) -
+ frame_table;
+ curr_update_phys <<= PAGE_SHIFT;
+ pgt_updates = map_domain_mem(curr_update_phys);
}
}
unmap_domain_mem((void *)((unsigned long)(pgt_updates-1) & PAGE_MASK));
static unsigned long alloc_page_from_domain(unsigned long * cur_addr,
unsigned long * index)
{
- *cur_addr = (frame_table + (*cur_addr >> PAGE_SHIFT))->prev << PAGE_SHIFT;
+ struct list_head *ent = frame_table[*cur_addr >> PAGE_SHIFT].list.prev;
+ *cur_addr = list_entry(ent, struct pfn_info, list) - frame_table;
+ *cur_addr <<= PAGE_SHIFT;
(*index)--;
return *cur_addr;
}
*/
int setup_guestos(struct task_struct *p, dom0_newdomain_t *params)
{
+ struct list_head *list_ent;
char *src, *dst;
int i, dom = p->domain;
unsigned long phys_l1tab, phys_l2tab;
machine_to_phys_mapping[cur_address >> PAGE_SHIFT] = count;
}
- cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT;
+ list_ent = frame_table[cur_address >> PAGE_SHIFT].list.next;
+ cur_address = list_entry(list_ent, struct pfn_info, list) -
+ frame_table;
+ cur_address <<= PAGE_SHIFT;
}
unmap_domain_mem(l1start);
cur_address = p->pg_head << PAGE_SHIFT;
for ( count = 0; count < alloc_index; count++ )
{
- cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT;
+ list_ent = frame_table[cur_address >> PAGE_SHIFT].list.next;
+ cur_address = list_entry(list_ent, struct pfn_info, list) -
+ frame_table;
+ cur_address <<= PAGE_SHIFT;
}
l2tab = l2start + l2_table_offset(virt_load_address +
page->flags = dom | PGT_l1_page_table;
page->tot_count++;
- cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT;
+ list_ent = frame_table[cur_address >> PAGE_SHIFT].list.next;
+ cur_address = list_entry(list_ent, struct pfn_info, list) -
+ frame_table;
+ cur_address <<= PAGE_SHIFT;
}
page->flags = dom | PGT_l2_page_table;
unmap_domain_mem(l1start);
if (TASK_SIZE - len < addr)
return -ENOMEM;
- if(current->pid > 100){
- printk(KERN_ALERT "bd240 debug: gua: vm addr found %lx\n", addr);
- printk(KERN_ALERT "bd240 debug: gua: first condition %d, %lx, %lx\n",vma, addr + len, vma->vm_start);
- printk(KERN_ALERT "bd240 debug: gua: second condition %d\n", direct_mapped(addr));
- }
if ((!vma || addr + len <= vma->vm_start) && !direct_mapped(addr))
return addr;
for ( curr = direct_list->next; curr != direct_list; curr = curr->next )
{
node = list_entry(curr, direct_mmap_node_t, list);
- if( node->vm_start >= addr ){
- printk(KERN_ALERT "bd240 debug: find_direct: hit %lx\n", node->vm_start);
- break;
- }
+ if ( node->vm_start >= addr ) break;
}
return curr;